<?php
class Model_ArticleCategory extends Zend_Db_Table {
	
	/**
	 * name of the table
	 *
	 * @var string
	 */
		
	protected $_name = 'hl_articles_categories';
	
	public function init() {}
	
	public function get($filters, $order = null) {
		$select = $this->select()
    					->setIntegrityCheck(false)
    					->from(array('ac' => $this->_name));
		
    	foreach($filters AS $key => $value) {
    		
    		/** TODO
    			If "extra" field
    		*/
    		
    		// If is array, IN()
    		if(is_array($value)) {
    			$temp = '';
    			foreach($value AS $val) {
    				$temp .= '"' . $val . '",';
    			}
    			$temp = trim($temp, ',');
    			
    			$select->where('LOWER(ac.'.$key . ') IN ('.$temp.')');
    		
    		// Else	
    		} else {
				$select->where('LOWER(ac.'.$key . ') = ?', $value);
			}
    	}
			
		if(!is_null($order)) {
			$select->order($order);
		}
		
		$result_temp = $this->fetchAll($select);
		
		$result = Model_Tools::stripslashes($result_temp);
		
    	return $result;
	}
	
}
?>
